package com.ruoyi.yipaiju.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yipaiju.domain.StorageRelationship;
import com.ruoyi.yipaiju.service.IStorageRelationshipService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * fo_storage_relationshipController
 * 
 * @author liuwp
 * @date 2023-03-01
 */
@RestController
@RequestMapping("/yipaiju/storage_relationship")
public class StorageRelationshipController extends BaseController
{
    @Autowired
    private IStorageRelationshipService storageRelationshipService;

    /**
     * 查询fo_storage_relationship列表
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:storage_relationship:list')")
    @GetMapping("/list")
    public TableDataInfo list(StorageRelationship storageRelationship)
    {
        startPage();
        List<StorageRelationship> list = storageRelationshipService.selectStorageRelationshipList(storageRelationship);
        return getDataTable(list);
    }

    /**
     * 导出fo_storage_relationship列表
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:storage_relationship:export')")
    @Log(title = "fo_storage_relationship", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StorageRelationship storageRelationship)
    {
        List<StorageRelationship> list = storageRelationshipService.selectStorageRelationshipList(storageRelationship);
        ExcelUtil<StorageRelationship> util = new ExcelUtil<StorageRelationship>(StorageRelationship.class);
        util.exportExcel(response, list, "fo_storage_relationship数据");
    }

    /**
     * 获取fo_storage_relationship详细信息
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:storage_relationship:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(storageRelationshipService.selectStorageRelationshipById(id));
    }

    /**
     * 新增fo_storage_relationship
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:storage_relationship:add')")
    @Log(title = "fo_storage_relationship", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StorageRelationship storageRelationship)
    {
        return toAjax(storageRelationshipService.insertStorageRelationship(storageRelationship));
    }

    /**
     * 修改fo_storage_relationship
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:storage_relationship:edit')")
    @Log(title = "fo_storage_relationship", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StorageRelationship storageRelationship)
    {
        return toAjax(storageRelationshipService.updateStorageRelationship(storageRelationship));
    }

    /**
     * 删除fo_storage_relationship
     */
    @PreAuthorize("@ss.hasPermi('yipaiju:storage_relationship:remove')")
    @Log(title = "fo_storage_relationship", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(storageRelationshipService.deleteStorageRelationshipByIds(ids));
    }
}
